package com.tiger.web.controller.project;

import com.tiger.common.annotation.Log;
import com.tiger.common.core.controller.BaseController;
import com.tiger.common.core.domain.AjaxResult;
import com.tiger.common.core.domain.model.LoginUser;
import com.tiger.common.core.page.TableDataInfo;
import com.tiger.common.enums.BusinessType;
import com.tiger.common.utils.ServletUtils;
import com.tiger.common.utils.spring.SpringUtils;
import com.tiger.framework.web.service.TokenService;
import com.tiger.project.domain.ProjectArchive;
import com.tiger.project.service.IProjectArchiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 【项目档案】Controller
 *
 * @author standard
 * @date 2022-09-19
 */
@Api(tags = "项目档案")
@RestController
@RequestMapping("/system/archive")
public class ProjectArchiveController extends BaseController {
    @Autowired
    private IProjectArchiveService projectArchiveService;

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation(value = "查询【项目档案】列表")
    //@PreAuthorize("@ss.hasPermi('system:archive:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectArchive projectArchive) {
        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
        projectArchive.setCompanyId(loginUser.getUser().getDeptId());
        startPage();
        List<ProjectArchive> list = projectArchiveService.selectProjectArchiveList(projectArchive);
        return getDataTable(list);
    }


    /**
     * 获取【项目档案】详细信息
     */
    @ApiOperation(value = "获取【项目档案】列详细信息")
    //@PreAuthorize("@ss.hasPermi('system:archive:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(projectArchiveService.selectProjectArchiveById(id));
    }

    /**
     * 新增【项目档案】
     */
//    @ApiOperation(value = "新增【项目档案】")
//    //@PreAuthorize("@ss.hasPermi('system:archive:add')")
//    @Log(title = "【项目档案】", businessType = BusinessType.INSERT)
//    @PostMapping("/add")
//    public AjaxResult add(@RequestBody ProjectArchive projectArchive) {
//        return toAjax(projectArchiveService.insertProjectArchive(projectArchive));
//    }

    /**
     * 修改【项目档案】
     */
    @ApiOperation(value = "项目归档")
    //@PreAuthorize("@ss.hasPermi('system:archive:edit')")
//    @Log(title = "修改【项目档案】", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ProjectArchive projectArchive) {
        return toAjax(projectArchiveService.updateProjectArchive(projectArchive));
    }

    /**
     * 删除【项目档案】
     */
//   @ApiOperation(value = "删除【项目档案】")
//    //@PreAuthorize("@ss.hasPermi('system:archive:remove')")
//    @Log(title = "【项目档案】", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids) {
//        return toAjax(projectArchiveService.deleteProjectArchiveByIds(ids));
//    }
}
